import React,{Component} from 'react'
import Login from './account/Login'
import Demo from './Demo'
import UserInfo from './account/UserInfo'
import Tabbar from './tabbar'
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import {inject,observer} from 'mobx-react'
const Stack = createStackNavigator();

@inject('rootStore')
@observer
class Nav extends Component {
    constructor(props){
        super(props)
        this.state ={
            initialRouteName:this.props.rootStore.token?'Tabbar':'Login'
        }
    }
    render() { 
        const {initialRouteName} = this.state
        return ( 
            <NavigationContainer>
                <Stack.Navigator headerMode='none' initialRouteName={initialRouteName}>
                    <Stack.Screen name="Demo" component={Demo} />
                    <Stack.Screen name="Tabbar" component={Tabbar} />
                    <Stack.Screen name="Login" component={Login} />
                    <Stack.Screen name="UserInfo" component={UserInfo} />
                </Stack.Navigator>
            </NavigationContainer>
        );
    }
}
 
export default Nav;